/**
 * Created by cjl on 2017/7/15.
 */
import React, {Component} from 'react';
import {Text, View, AppRegistry, Button} from "react-native";

import {NativeModules} from 'react-native';

export default class test extends Component {

  props

  constructor(p) {
    super(p)
    props = p;
  }

  render() {
    return (
      <View>
        <Text>
          Welcome to React Native!
        </Text>
        <Text>
          To get started, edit test.js
        </Text>

        <Text>
          {this.props.random}
        </Text>

        <Button title={"点击"} onPress={() => this.newPage()}/>
        <Button title={"quit"} onPress={() => this.closePage()}/>

      </View>
    )
  }

  newPage() {
    var route = NativeModules.RouteModule;
    let r = Math.random();
    var params = {
      "b->c": " hello world",
      "random": r
    };

    var moduleName = `test`;
    route.newPageWithJsName("test", moduleName, params);
    // AppRegistry.runApplication(moduleName,params)
  }

  closePage() {
    var route = NativeModules.RouteModule;
    route.dismissNow();
  }
}

AppRegistry.registerComponent('test', () => test);